package channel;

import handler.HandlerSingleFactory;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;


/**
 * @author yuzk
 * @date 2018/1/12
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel>{

    private static final StringDecoder DECODER = new StringDecoder();
    private static final StringEncoder ENCODER = new StringEncoder();

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline()
                .addLast(DECODER)
                .addLast(ENCODER)
                .addLast(HandlerSingleFactory.getMyServerHandler());
    }
}
